Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement ParticleGeometryBuffer. #52

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

player-03
Copy link
Contributor

@player-03 player-03 commented Apr 22, 2023

This offers more ways to define particles, and provides some much-needed documentation. (If we'd had this documentation beforehand, I wouldn't have gotten confused and submitted #51.)

Take the basic Particles sample. It creates a ParticleGeometry like so:

var plane:Geometry = new PlaneGeometry(10, 10, 1, 1, false);
var geometrySet:Vector<Geometry> = new Vector<Geometry>();
for (i in 0...20000)
	geometrySet.push(plane);

//...

_particleMesh = new Mesh(ParticleGeometryHelper.generateGeometry(geometrySet), material);

This is the most common use case for particles: a ton of copies of a single thing. So why should you have to allocate a vector of 20000 items? ParticleGeometryBuffer has a function specifically for this, making the process that much easier.

var buffer:ParticleGeometryBuffer = new ParticleGeometryBuffer();
buffer.addParticles(new PlaneGeometry(10, 10, 1, 1, false), 20000);

//...

_particleMesh = new Mesh(buffer.getParticleGeometry(), material);

There's also a function to add particles one at a time if that's more convenient, or you can keep using ParticleGeometryHelper as if nothing changed.

Supersedes #49.

This class offers more ways to define particles, and provides some
much-needed documentation.
This was essentially just an old name for `addParticle()`, and I forgot to delete it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant